from pymysql import cursors
import hashlib
import pymysql


def make_password(password):
    md5 = hashlib.md5()
    str1 = str(password).encode(encoding='utf-8')
    md5.update(str1)
    return md5.hexdigest()

class Dbb:
    def __init__(self):
        self.conn =pymysql.connect(host='localhost',user='root',password='hxy',db='myflask',charset='utf8',
        cursorclass=pymysql.cursors.DictCursor) 
        self.cursor = self.conn.cursor()
    def insert(self,sql):
        self.cursor.execute(sql)
        self.conn.commit()
        return 'insert ok'
    def get_one(self,sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchone()
        return res

# db = Dbb()
# # print(db.insert("insert into `uuser` values(0,'黄秀1丽','hhh','12345678')"))
# print(db.get_one("select * from `uuser` where `username`='hxy'"))
